using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using SD = Microsoft.Practices.RepositoryFactory.SchemaDiscovery.ObjectModel.Base;
using Microsoft.Practices.RepositoryFactory.CustomPages.Helpers;
using Microsoft.Practices.RepositoryFactory.CodeGeneration.ObjectModel;

namespace Microsoft.Practices.RepositoryFactory.CustomPages.UI
{
    /// <summary/>
    internal class DataBaseNode : TreeNode
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="T:DataBaseNode"/> class.
        /// </summary>
        /// <param name="text">The text.</param>
        public DataBaseNode(string text)
        {
            base.Text = text;
            base.Tag = null;
            base.ImageIndex = 7;
            base.SelectedImageIndex = 7;
        }
    }

    /// <summary/>
    internal class FolderNode : TreeNode
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="T:FolderNode"/> class.
        /// </summary>
        /// <param name="text">The text.</param>
        public FolderNode(string text)
        {
            base.Text = text;
            base.Tag = null;
            base.ImageIndex = 6;
            base.SelectedImageIndex = 6;
        }
    }

    /// <summary/>
    internal class TableNode : TreeNode
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="T:TableNode"/> class.
        /// </summary>
        /// <param name="table">The table.</param>
        public TableNode(SD.Table table)
        {
            base.Text = table.FullName;
            base.Tag = table;
            base.ImageIndex = 5;
            base.SelectedImageIndex = 5;
        }
    }

    /// <summary/>
    internal class ViewNode : TreeNode
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="T:ViewNode"/> class.
        /// </summary>
        /// <param name="view">The view.</param>
        public ViewNode(SD.View view)
        {
            base.Text = view.FullName;
            base.Tag = view;
            base.ImageIndex = 0;
            base.SelectedImageIndex = 0;
        }
    }

    /// <summary/>
    internal class EntityNode : TreeNode
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="T:EntityNode"/> class.
        /// </summary>
        /// <param name="entity">The entity.</param>
        public EntityNode(Entity entity)
        {
            base.Text = entity.Name;
            base.Tag = entity;
            base.ImageIndex = 5;
            base.SelectedImageIndex = 5;
        }
    }

    /// <summary/>
    internal class PropertyNode : TreeNode
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="T:PropertyNode"/> class.
        /// </summary>
        /// <param name="property">The property.</param>
        public PropertyNode(Property property)
        {
            base.Text = property.Name;
            base.Tag = property;
            base.ImageIndex = 1;
            base.SelectedImageIndex = 1;
        }
    }

    /// <summary/>
    internal class ColumnNode : TreeNode
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="T:ColumnNode"/> class.
        /// </summary>
        /// <param name="column">The column.</param>
        public ColumnNode(SD.Column column)
        {
            base.Text = NodesHelper.GenerateColumnText(column);
            base.Tag = column;
            if(!column.IsPrimaryKey)
            {
                base.ImageIndex = 1;
                base.SelectedImageIndex = 1;
            }
            else
            {
                base.ImageIndex = 8;
                base.SelectedImageIndex = 8;
            }
        }
    }

    /// <summary/>
    internal class StoredProcedureNode : TreeNode
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="T:StoredProcedureNode"/> class.
        /// </summary>
        /// <param name="storedProcedure">The stored procedure.</param>
        public StoredProcedureNode(SD.StoredProcedure storedProcedure)
        {
            base.Text = storedProcedure.Name;
            base.Tag = storedProcedure;
            base.ImageIndex = 4;
            base.SelectedImageIndex = 4;
        }
    }

    /// <summary/>
    internal class InputParameterNode : TreeNode
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="T:InputParameterNode"/> class.
        /// </summary>
        /// <param name="parameter">The parameter.</param>
        public InputParameterNode(SD.Parameter parameter)
        {
            base.Text = NodesHelper.GenerateParameterText(parameter);
            base.Tag = parameter;
            base.ImageIndex = 2;
            base.SelectedImageIndex = 2;
        }
    }

    /// <summary/>
    internal class OutputParameterNode : TreeNode
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="T:OutputParameterNode"/> class.
        /// </summary>
        /// <param name="parameter">The parameter.</param>
        public OutputParameterNode(SD.Parameter parameter)
        {
            base.Text = NodesHelper.GenerateParameterText(parameter);
            base.Tag = parameter;
            base.ImageIndex = 3;
            base.SelectedImageIndex = 3;
        }
    }

    /// <summary/>
    internal class InputOutputParameterNode : TreeNode
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="T:InputOutputParameterNode"/> class.
        /// </summary>
        /// <param name="parameter">The parameter.</param>
        public InputOutputParameterNode(SD.Parameter parameter)
        {
            base.Text = NodesHelper.GenerateParameterText(parameter);
            base.Tag = parameter;
            base.ImageIndex = 3;
            base.SelectedImageIndex = 3;
        }
    }
}